package system

import (
	"github.com/gin-gonic/gin"
	"go-api-template/api/http"
	"go-api-template/service"
)

type StatusReq struct {
}
type StatusResp struct {
	DB StatusRespDB
}
type StatusRespDB struct {
	OpenConnections int
}

func (req *StatusReq) Request(ctx *gin.Context, s *service.Service) (http.Resp, error) {
	return req.Do(ctx, s)
}
func (req *StatusReq) Do(ctx *gin.Context, s *service.Service) (resp http.Resp, err error) {
	var data StatusResp

	db, _ := s.Db.DB()
	dbStats := db.Stats()

	data.DB.OpenConnections = dbStats.OpenConnections

	resp.SetData(data)
	return
}
